<script setup lang="ts" name="Tools">
import { getToken, getwxacodeunlimit, generateUrlLink } from "@/api/index";
import { reactive, ref } from "vue";
import { showFailToast, showSuccessToast } from "vant";
import "vant/es/toast/style";

const createQrCode = async () => {
  const data: any = await getToken({
    grant_type: "client_credential",
    // appid: "wx7bb6dc7f6bb17b30",
    // secret: "b313ab05e2050e0d582927ca23629493"
    appid: "wxb918c1b0fbced2ca",
    secret: "9317351650c4ba545ad7ef4f3c2cebc6"
  });
  await getwxacodeunlimit({
    access_token: data.access_token,
    scene: "url=https://yan.zszhyl.com/login",
    page: "pages/standard-mode/webview"
  });
};

const createScheme = async () => {
  const data: any = await getToken({
    grant_type: "client_credential",
    appid: "wxb918c1b0fbced2ca",
    secret: "9317351650c4ba545ad7ef4f3c2cebc6"
  });

  const res: any = await generateUrlLink({
    access_token: data.access_token,
    page: "/pages/index/index"
  });
  location.href = res.url_link;
};

const to = () => {
  location.href =
    "weixin://dl/business/?appid=wxb918c1b0fbced2ca&path=pages/index/index&env_version=trial";
};
</script>

<template>
  <div class="tools-content pt-[20px] px-[12px]">
    <div class="pl-[12px] border-l-[3px] border-[color:#41b883] mb-[12px]">
      <h3 class="font-bold text-[18px] my-[4px]">Mock</h3>
    </div>
    <van-button @click="createQrCode" block> 获取不限制的二维码</van-button>
    <van-divider></van-divider>
    <van-button @click="createScheme" block>获取scheme码</van-button>
    <van-divider></van-divider>
    <van-button @click="to" block>明文URLScheme跳转</van-button>
  </div>
</template>

<style lang="less"></style>
